home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: gets(rec->num); I don't know what I am doing wrong...
- Date: 9 Feb 1996 12:39:04 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4fff98$fv0@sparcserver.lrz-muenchen.de>
- References: <4fempt$mjg@aphex.direct.ca>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- etoivane@direct.ca (Ed Toivanen) writes:
-
- >I posted the code that I wrote so far. I can't make gets(rec->id); work
- >properly, I get 6 or 7 compilation errors indicating that parameter 1
- >does not
- >match function prototype. Each gets() call is incorrect! What to do?
-
- [some definitions edited]
-
- >typedef struct student_record{
- > int id; /* Range: 1..99, Unique */
- > char name[NAME_LEN + 1]; /* Non-unique */
- > PROGRAM major;
- > MARK marks;
- >} STUDENT_RECORD;
-
- [some prototypes edited]
-
- >int main(void){
- > char studentList[8 + 1];
- > FILE * filePtr;
-
- > printf("Enter database file to open\n");
- > while(!gets(studentList))
- > {}
-
- You should not get a diagnostic for this call to gets(), and you
- should not use gets(), but that is a completely different topic.
-
- >
- > if(!initList(studentList, filePtr)){
- > return(1);
- > }
-
- > return(0);
- >}
-
- >bool addRecord(FILE* fp, STUDENT_RECORD* rec){
- > printf("Student id\n");
- > gets(rec->id);
- >
-
- gets() expects a pointer to char, doesn't it? Hint: gets() is _not_
- the same as readln() in a completly different language.
-
- > printf("Student's last name first\n");
- > gets(rec->name);
-
- This call to gets() should not produce a diagnostic, because this
- time you pass an argument that has the expected type.
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
- | ua302aa@sunmail.lrz-muenchen.de
-